package com.briup.day09;

import java.util.Objects;

/**
 * @author lining
 * @date 2024/1/18 17:12
 */
public class Teacher {
    private String name;
    private String address;
    private Double salary;

    public Teacher() {
    }

    public Teacher(String name, String address, Double salary) {
        this.name = name;
        this.address = address;
        this.salary = salary;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Teacher teacher = (Teacher) o;
        return Objects.equals(name, teacher.name) && Objects.equals(address, teacher.address) && Objects.equals(salary, teacher.salary);
    }
    //判断2个老师对象是否相同（name+address+salary）。如何编写代码实现？？？
//    public boolean equals(Object obj){
//        //1.判断类型
//        if(obj instanceof Teacher){
//            Teacher t = (Teacher) obj;
//            //属性值进行判断 名字内容是否相同
//            if(this.name.equals(t.name) &&
//                    this.address.equals(t.address) &&
//                        salary.equals(t.salary)){
//                return true;
//            }
//        }
//        //2.2个类型不同。不是一个老师信息
//        return false;
//    }

    @Override
    public int hashCode() {
        //工具类Arrays  Objects
//        return id;
//        return name.hashcode()+ address.hashcode() +salary.hashcode()
        return Objects.hash(name, address, salary);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Double getSalary() {
        return salary;
    }

    public void setSalary(Double salary) {
        this.salary = salary;
    }
}
